

import Foundation


class LogEntry: Codable{
    // 手机id 随机生成
    var aid: String

    // 各个事件的名字 e：open load..
    var position: String

    // 具体事件 e：RequestAd...
    var status: String

    // 广告id
    var uid: String

    // 上传内容 e：请求广告花的时间... 或者其他用处 自己想打事件都可以放在这里面
    var info: String

    // 广告价值单位 adValue.currencyCode
    var currency: String

    // 广告价值 adValue.valueMicros.toString()
    var cicros: String

    // 手机系统版本
    var androidVersionCode: String

    // 包名
    var pkg: String

    // appversioncode
    var appVersionCode: String

    // 广告请求失败原因
    var errorinfo: String

    // Facebook 深度链接
    var applink: String

    // Google refer
    var refer: String

    var iosLink:String
    
    init(
        aid: String = getUserId(),
         position: String ,
         status: String ,
         uid: String ,
         info: String ,
         currency: String ,
         cicros: String,
         androidVersionCode: String  = getiOSVersion(),
         pkg: String = "org.zcl.converter.pdf",
         appVersionCode: String = getAppVersion() ?? "1.0.0",
         errorinfo: String = "",
         applink: String =  UserDefaultsManager.shared.getString(forKey: "fbLink") ?? "null",
         refer: String =  UserDefaultsManager.shared.getString(forKey: "referer") ?? "null",
        iosLink:String = UserDefaultsManager.shared.getString(forKey: "iosLink") ?? "null"
    ) {
        
        self.aid = aid
        self.position = position
        self.status = status
        self.uid = uid
        self.info = info
        self.currency = currency
        self.cicros = cicros
        self.androidVersionCode = androidVersionCode
        self.pkg = pkg
        self.appVersionCode = appVersionCode
        self.errorinfo = errorinfo
        self.applink = applink
        self.refer = refer
        self.iosLink=iosLink
    }
    
}


